package com.preserve.common.user.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.preserve.common.user.dao.IUsersDao;
import com.preserve.common.user.model.Users;
import com.preserve.common.user.service.IUsersService;
import com.preserve.core.dao.IBaseDao;
import com.preserve.core.service.impl.BaseServiceImpl;

/**
 * 用户业务接口实现
 * 
 * @author
 * @version 1.0 2013-05-08
 */

@Service(value="usersService")
public class UsersServiceImp extends BaseServiceImpl<Users> implements
		IUsersService {

	@Resource(name = "usersDao")
	private IUsersDao usersDao;

	@Override
	public IBaseDao<Users> getBaseDao() {
		// TODO Auto-generated method stub
		return usersDao;
	}

	public Users getUserByName(String name) {
		String sql = "select * from users where user_login=:name";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("name", name);
		List<Users> users = usersDao.find(sql, params);
		if (users != null && !users.isEmpty()) {
			return users.get(0);
		}
		return null;
	}

}
